<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
    <style>
      ul {
        width: 300px;
      }
      li {
        height: 40px;
        border-bottom: 1px solid #000;
      }
    </style>
  </head>
  <body>
    <div>
      <ul>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
        <li>1</li>
      </ul>
    </div>
    <script>
      const oLis = document.querySelectorAll("ul li");
      function enter() {
        console.log(1);
        this.style.background = "red";
      }
      function leave() {
        console.log(2);
        this.style.background = "";
      }

      const throttleEnter = _.throttle(enter, 30, {
        trailing: false,
        leading: true,
      });
      const throttleLeave = leave;

      oLis.forEach((item) => {
        item.onmouseenter = throttleEnter;
        item.onmouseleave = throttleLeave;
      });
    </script>
  </body>
</html>
